package heima3_2.cn.osc.presenter.synthesize_particulars_presenter;

import android.content.Context;

import java.util.List;

import heima3_2.cn.osc.constant.Constants;
import heima3_2.cn.osc.model.bean.GeneralNewsDetailBean;
import heima3_2.cn.osc.presenter.BasePresenter;
import heima3_2.cn.osc.ui.main_fragment.synthesize_particulars_fragment.ConsultParticularsFragment;
import heima3_2.cn.osc.utils.PreferencesUtils;
import retrofit2.Call;
import retrofit2.Response;

/**
 * Created by Administrator on 2017/1/17 0017.
 */

public class ConsultParticularsPresenter extends BasePresenter<GeneralNewsDetailBean> {
    private  ConsultParticularsFragment mConsultParticularsFragment;
    private  Context mContext;
    private List<GeneralNewsDetailBean> mListData;

    public  ConsultParticularsPresenter(Context context, ConsultParticularsFragment consultParticularsFragment){
                    this.mContext=context;
                    this.mConsultParticularsFragment=consultParticularsFragment;

        }
    @Override
    protected void getFailureData(Throwable t) {
        t.printStackTrace();
    }

    @Override
    protected void getSuccessData(Response<GeneralNewsDetailBean> response) {
        GeneralNewsDetailBean body = response.body();
        GeneralNewsDetailBean.NewsBean news = body.getNews();
       // String body1 = news.getBody();


                /*String mData="";
                mListData = new ArrayList<>();
                mListData.add(body);*/
                 //body

            mConsultParticularsFragment.mWvParticulars.loadUrl(news.getUrl());


    }

    @Override
    public void getData(int page) {
        int newsID = PreferencesUtils.getInt(mContext, Constants.NEWS_ID);
        System.out.println("newsID"+newsID);
        if(newsID!=0){
            Call<GeneralNewsDetailBean> info = mRetrofitInterface.getConsult(newsID);
            info.enqueue(mCallback);

        }
    }
}
